package exception;

public class DBValueException extends Exception {

	private final static String MESSAGE_FORMAT_BAD_SIZE_BOUNDS = "Invalid size for data, data has size %d, expected a size between %d and %d bytes.";
	private final static String MESSAGE_FORMAT_BAD_SIZE = "Invalid size for data, data has size %d, expected %d bytes.";
	
	private String message;

	@Override
	public String getMessage() {
		return message;
	};
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 5573460018851942802L;

	public static DBValueException dataSizeOutOfBounds(int lowerLimit, int upperLimit, int actualSize) {		
		DBValueException ex = new DBValueException();
		ex.message = String.format(MESSAGE_FORMAT_BAD_SIZE_BOUNDS, actualSize, lowerLimit, upperLimit);
		return ex;
	}

	public static DBValueException dataSizeMisMatch(int expectedSize, int actualSize) {
		DBValueException ex = new DBValueException();
		ex.message = String.format(MESSAGE_FORMAT_BAD_SIZE, actualSize, actualSize);
		return ex;
	}
	


}
